package com.rowenci.iot_agriculture.mapper;

import com.rowenci.iot_agriculture.bean.iot.Rfid;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;


public interface RfidDao extends JpaRepository<Rfid, Integer> {

    Rfid findByCarNumber(String carNumber);

    Rfid findRfidById(Integer id);

    @Transactional
    @Modifying
    @Query(value = "update Rfid rfid set rfid.carNumber = ?2 where rfid.id = ?1")
    void updateCarNumberById(Integer id, String carNumber);

}
